<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class OpenSSL::OCSP::Request - openssl: Ruby Standard Library Documentation</title>


<script src="../../js/navigation.js" defer></script>
<script src="../../js/search.js" defer></script>
<script src="../../js/search_index.js" defer></script>
<script src="../../js/searcher.js" defer></script>
<script src="../../js/darkfish.js" defer></script>

<script src="../../js/jquery-3.2.0.min.js"></script>

<script src="../../js/vue.min.js"></script>
<script src="../../js/js.cookie.min.js"></script>

<link href="../../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../../css/rdoc.css" rel="stylesheet">
<link href="../../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../../";
  var index_rel_prefix = "../../";
  var darkModeCsseHref = "../../css/rdoc-dm.css"
  var defaultModeCssHref = "../../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../../table_of_contents.html#pages">Pages</a>
    <a href="../../table_of_contents.html#classes">Classes</a>
    <a href="../../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link">Object
</div>

        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-new">::new</a>
    <li ><a href="#method-i-add_certid">#add_certid</a>
    <li ><a href="#method-i-add_nonce">#add_nonce</a>
    <li ><a href="#method-i-certid">#certid</a>
    <li ><a href="#method-i-check_nonce">#check_nonce</a>
    <li ><a href="#method-i-initialize_copy">#initialize_copy</a>
    <li ><a href="#method-i-sign">#sign</a>
    <li ><a href="#method-i-signed-3F">#signed?</a>
    <li ><a href="#method-i-to_der">#to_der</a>
    <li ><a href="#method-i-verify">#verify</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-OpenSSL::OCSP::Request">
    <h1 id="class-OpenSSL::OCSP::Request" class="class">
      class OpenSSL::OCSP::Request
    </h1>

    <section class="description">
    
<p>An <a href="Request.html"><code>OpenSSL::OCSP::Request</code></a> contains the certificate information for determining if a certificate has been revoked or not.  A <a href="Request.html"><code>Request</code></a> can be created for a certificate or from a DER-encoded request created elsewhere.</p>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">





                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-new" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          OpenSSL::OCSP::Request.new              &rarr; request
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          OpenSSL::OCSP::Request.new(request_der) &rarr; request
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Creates a new <a href="Request.html"><code>OpenSSL::OCSP::Request</code></a>.  The request may be created empty or from a <em>request_der</em> string.</p>

                              <div class="method-source-code" id="new-source">
            <pre>static VALUE
ossl_ocspreq_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE arg;
    OCSP_REQUEST *req, *req_new;
    const unsigned char *p;

    rb_scan_args(argc, argv, &quot;01&quot;, &amp;arg);
    if(!NIL_P(arg)){
        GetOCSPReq(self, req);
        arg = ossl_to_der_if_possible(arg);
        StringValue(arg);
        p = (unsigned char *)RSTRING_PTR(arg);
        req_new = d2i_OCSP_REQUEST(NULL, &amp;p, RSTRING_LEN(arg));
        if (!req_new)
            ossl_raise(eOCSPError, &quot;d2i_OCSP_REQUEST&quot;);
        SetOCSPReq(self, req_new);
        OCSP_REQUEST_free(req);
    }

    return self;
}</pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-add_certid" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          add_certid(certificate_id) &rarr; request
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Adds <em>certificate_id</em> to the request.</p>

                              <div class="method-source-code" id="add_certid-source">
            <pre>static VALUE
ossl_ocspreq_add_certid(VALUE self, VALUE certid)
{
    OCSP_REQUEST *req;
    OCSP_CERTID *id, *id_new;

    GetOCSPReq(self, req);
    GetOCSPCertId(certid, id);

    if (!(id_new = OCSP_CERTID_dup(id)))
        ossl_raise(eOCSPError, &quot;OCSP_CERTID_dup&quot;);
    if (!OCSP_request_add0_id(req, id_new)) {
        OCSP_CERTID_free(id_new);
        ossl_raise(eOCSPError, &quot;OCSP_request_add0_id&quot;);
    }

    return self;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-add_nonce" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          add_nonce(nonce = nil) &rarr; request
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Adds a <em>nonce</em> to the <a href="../OCSP.html"><code>OCSP</code></a> request.  If no nonce is given a random one will be generated.</p>

<p>The nonce is used to prevent replay attacks but some servers do not support it.</p>

                              <div class="method-source-code" id="add_nonce-source">
            <pre>static VALUE
ossl_ocspreq_add_nonce(int argc, VALUE *argv, VALUE self)
{
    OCSP_REQUEST *req;
    VALUE val;
    int ret;

    rb_scan_args(argc, argv, &quot;01&quot;, &amp;val);
    if(NIL_P(val)) {
        GetOCSPReq(self, req);
        ret = OCSP_request_add1_nonce(req, NULL, -1);
    }
    else{
        StringValue(val);
        GetOCSPReq(self, req);
        ret = OCSP_request_add1_nonce(req, (unsigned char *)RSTRING_PTR(val), RSTRING_LENINT(val));
    }
    if(!ret) ossl_raise(eOCSPError, NULL);

    return self;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-certid" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          certid &rarr; [certificate_id, ...]
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns all certificate IDs in this request.</p>

                              <div class="method-source-code" id="certid-source">
            <pre>static VALUE
ossl_ocspreq_get_certid(VALUE self)
{
    OCSP_REQUEST *req;
    OCSP_ONEREQ *one;
    OCSP_CERTID *id;
    VALUE ary, tmp;
    int i, count;

    GetOCSPReq(self, req);
    count = OCSP_request_onereq_count(req);
    ary = (count &gt; 0) ? rb_ary_new() : Qnil;
    for(i = 0; i &lt; count; i++){
        one = OCSP_request_onereq_get0(req, i);
        tmp = NewOCSPCertId(cOCSPCertId);
        if(!(id = OCSP_CERTID_dup(OCSP_onereq_get0_id(one))))
            ossl_raise(eOCSPError, NULL);
        SetOCSPCertId(tmp, id);
        rb_ary_push(ary, tmp);
    }

    return ary;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-check_nonce" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          check_nonce(response) &rarr; result
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Checks the nonce validity for this request and <em>response</em>.</p>

<p>The return value is one of the following:</p>
<dl class="rdoc-list note-list"><dt>-1 
<dd>
<p>nonce in request only.</p>
</dd><dt>0 
<dd>
<p>nonces both present and not equal.</p>
</dd><dt>1 
<dd>
<p>nonces present and equal.</p>
</dd><dt>2 
<dd>
<p>nonces both absent.</p>
</dd><dt>3 
<dd>
<p>nonce present in response only.</p>
</dd></dl>

<p>For most responses, clients can check <em>result</em> &gt; 0.  If a responder doesn’t handle nonces <code>result.nonzero?</code> may be necessary.  A result of <code>0</code> is always an error.</p>

                              <div class="method-source-code" id="check_nonce-source">
            <pre>static VALUE
ossl_ocspreq_check_nonce(VALUE self, VALUE basic_resp)
{
    OCSP_REQUEST *req;
    OCSP_BASICRESP *bs;
    int res;

    GetOCSPReq(self, req);
    GetOCSPBasicRes(basic_resp, bs);
    res = OCSP_check_nonce(req, bs);

    return INT2NUM(res);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-initialize_copy" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">initialize_copy</span><span
                                class="method-args">(p1)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="initialize_copy-source">
            <pre>static VALUE
ossl_ocspreq_initialize_copy(VALUE self, VALUE other)
{
    OCSP_REQUEST *req, *req_old, *req_new;

    rb_check_frozen(self);
    GetOCSPReq(self, req_old);
    GetOCSPReq(other, req);

    req_new = ASN1_item_dup(ASN1_ITEM_rptr(OCSP_REQUEST), req);
    if (!req_new)
        ossl_raise(eOCSPError, &quot;ASN1_item_dup&quot;);

    SetOCSPReq(self, req_new);
    OCSP_REQUEST_free(req_old);

    return self;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-sign" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          sign(cert, key, certs = nil, flags = 0, digest = nil) &rarr; self
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Signs this <a href="../OCSP.html"><code>OCSP</code></a> request using <em>cert</em>, <em>key</em> and optional <em>digest</em>. If <em>digest</em> is not specified, SHA-1 is used. <em>certs</em> is an optional Array of additional certificates which are included in the request in addition to the signer certificate. Note that if <em>certs</em> is <code>nil</code> or not given, flag OpenSSL::OCSP::NOCERTS is enabled. Pass an empty array to include only the signer certificate.</p>

<p><em>flags</em> is a bitwise OR of the following constants:</p>
<dl class="rdoc-list note-list"><dt>OpenSSL::OCSP::NOCERTS
<dd>
<p>Don’t include any certificates in the request. <em>certs</em> will be ignored.</p>
</dd></dl>

                              <div class="method-source-code" id="sign-source">
            <pre>static VALUE
ossl_ocspreq_sign(int argc, VALUE *argv, VALUE self)
{
    VALUE signer_cert, signer_key, certs, flags, digest;
    OCSP_REQUEST *req;
    X509 *signer;
    EVP_PKEY *key;
    STACK_OF(X509) *x509s = NULL;
    unsigned long flg = 0;
    const EVP_MD *md;
    int ret;

    rb_scan_args(argc, argv, &quot;23&quot;, &amp;signer_cert, &amp;signer_key, &amp;certs, &amp;flags, &amp;digest);
    GetOCSPReq(self, req);
    signer = GetX509CertPtr(signer_cert);
    key = GetPrivPKeyPtr(signer_key);
    if (!NIL_P(flags))
        flg = NUM2INT(flags);
    if (NIL_P(digest))
        md = NULL;
    else
        md = ossl_evp_get_digestbyname(digest);
    if (NIL_P(certs))
        flg |= OCSP_NOCERTS;
    else
        x509s = ossl_x509_ary2sk(certs);

    ret = OCSP_request_sign(req, signer, key, md, x509s, flg);
    sk_X509_pop_free(x509s, X509_free);
    if (!ret) ossl_raise(eOCSPError, NULL);

    return self;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-signed-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          signed? &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if the request is signed, <code>false</code> otherwise. Note that the validity of the signature is <strong>not</strong> checked. Use <a href="Request.html#method-i-verify"><code>verify</code></a> to verify that.</p>

                              <div class="method-source-code" id="signed-3F-source">
            <pre>static VALUE
ossl_ocspreq_signed_p(VALUE self)
{
    OCSP_REQUEST *req;

    GetOCSPReq(self, req);
    return OCSP_request_is_signed(req) ? Qtrue : Qfalse;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-to_der" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">to_der</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns this request as a DER-encoded string</p>

                              <div class="method-source-code" id="to_der-source">
            <pre>static VALUE
ossl_ocspreq_to_der(VALUE self)
{
    OCSP_REQUEST *req;
    VALUE str;
    unsigned char *p;
    long len;

    GetOCSPReq(self, req);
    if((len = i2d_OCSP_REQUEST(req, NULL)) &lt;= 0)
        ossl_raise(eOCSPError, NULL);
    str = rb_str_new(0, len);
    p = (unsigned char *)RSTRING_PTR(str);
    if(i2d_OCSP_REQUEST(req, &amp;p) &lt;= 0)
        ossl_raise(eOCSPError, NULL);
    ossl_str_adjust(str, p);

    return str;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-verify" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          verify(certificates, store, flags = 0) &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Verifies this request using the given <em>certificates</em> and <em>store</em>. <em>certificates</em> is an array of <a href="../X509/Certificate.html"><code>OpenSSL::X509::Certificate</code></a>, <em>store</em> is an <a href="../X509/Store.html"><code>OpenSSL::X509::Store</code></a>.</p>

<p>Note that <code>false</code> is returned if the request does not have a signature. Use <a href="Request.html#method-i-signed-3F"><code>signed?</code></a> to check whether the request is signed or not.</p>

                              <div class="method-source-code" id="verify-source">
            <pre>static VALUE
ossl_ocspreq_verify(int argc, VALUE *argv, VALUE self)
{
    VALUE certs, store, flags;
    OCSP_REQUEST *req;
    STACK_OF(X509) *x509s;
    X509_STORE *x509st;
    int flg, result;

    rb_scan_args(argc, argv, &quot;21&quot;, &amp;certs, &amp;store, &amp;flags);
    GetOCSPReq(self, req);
    x509st = GetX509StorePtr(store);
    flg = NIL_P(flags) ? 0 : NUM2INT(flags);
    x509s = ossl_x509_ary2sk(certs);
    result = OCSP_request_verify(req, x509s, x509st, flg);
    sk_X509_pop_free(x509s, X509_free);
    if (result &lt;= 0)
        ossl_clear_error();

    return result &gt; 0 ? Qtrue : Qfalse;
}</pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>. </p><p><a href="https://jamesbritt.bandcamp.com/">Hack your world.  Feed your head.  Live curious</a>.</p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

